Also print the commands only right before they're actually run.
Closes #215
+use std::io::IoResult;
+
+use core::MultiShell;
use util::{CargoResult, Fresh, Dirty, Freshness};
-pub struct Job { dirty: Work, fresh: Work }
+pub struct Job { dirty: Work, fresh: Work, desc: String }
pub type Work = proc():Send -> CargoResult<()>;
impl Job {
/// Create a new job representing a unit of work.
pub fn new(dirty: proc():Send -> CargoResult<()>,
- fresh: proc():Send -> CargoResult<()>) -> Job {
- Job { dirty: dirty, fresh: fresh }
+ fresh: proc():Send -> CargoResult<()>,
+ desc: String) -> Job {
+ Job { dirty: dirty, fresh: fresh, desc: desc }
}
/// Consumes this job by running it, returning the result of the
Dirty => (self.dirty)(),
}
}
+
+ pub fn describe(&self, shell: &mut MultiShell) -> IoResult<()> {
+ if self.desc.len() > 0 {
+ try!(shell.status("Running", self.desc.as_slice()));
+ }
+ Ok(())
+ }
}
let fresh = job_freshness.combine(fresh);
let my_tx = self.tx.clone();
let id = id.clone();
+ if fresh == Dirty {
+ try!(config.shell().verbose(|shell| job.describe(shell)));
+ }
self.pool.execute(proc() {
my_tx.send((id, stage, fresh, job.run(fresh)));
});
// Prepare the fingerprint directory as the first step of building a package
let (target1, target2) = fingerprint::prepare_init(cx, pkg, KindTarget);
- let mut init = vec![(Job::new(target1, target2), Fresh)];
+ let mut init = vec![(Job::new(target1, target2, String::new()), Fresh)];
if cx.config.target().is_some() {
let (plugin1, plugin2) = fingerprint::prepare_init(cx, pkg, KindPlugin);
- init.push((Job::new(plugin1, plugin2), Fresh));
+ init.push((Job::new(plugin1, plugin2, String::new()), Fresh));
}
jobs.enqueue(pkg, StageStart, init);
}
let (freshness, dirty, fresh) =
try!(fingerprint::prepare_build_cmd(cx, pkg));
+ let desc = match build_cmds.len() {
+ 0 => String::new(),
+ 1 => pkg.get_manifest().get_build()[0].to_string(),
+ _ => format!("custom build commands"),
+ };
let dirty = proc() {
for cmd in build_cmds.move_iter() { try!(cmd()) }
dirty()
};
- jobs.enqueue(pkg, StageCustomBuild, vec![(Job::new(dirty, fresh), freshness)]);
+ jobs.enqueue(pkg, StageCustomBuild, vec![(Job::new(dirty, fresh, desc),
+ freshness)]);
// After the custom command has run, execute rustc for all targets of our
// package.
let (mut libs, mut bins) = (Vec::new(), Vec::new());
for &target in targets.iter() {
let work = if target.get_profile().is_doc() {
- vec![(try!(rustdoc(pkg, target, cx)), KindTarget)]
+ let (rustdoc, desc) = try!(rustdoc(pkg, target, cx));
+ vec![(rustdoc, KindTarget, desc)]
} else {
let req = cx.get_requirement(pkg, target);
try!(rustc(pkg, target, cx, req))
};
let dst = if target.is_lib() {&mut libs} else {&mut bins};
- for (work, kind) in work.move_iter() {
+ for (work, kind, desc) in work.move_iter() {
let (freshness, dirty, fresh) =
try!(fingerprint::prepare_target(cx, pkg, target, kind));
let dirty = proc() { try!(work()); dirty() };
- dst.push((Job::new(dirty, fresh), freshness));
+ dst.push((Job::new(dirty, fresh, desc), freshness));
}
}
jobs.enqueue(pkg, StageLibraries, libs);
fn rustc(package: &Package, target: &Target,
cx: &mut Context, req: PlatformRequirement)
- -> CargoResult<Vec<(Work, Kind)> >{
+ -> CargoResult<Vec<(Work, Kind, String)> >{
let crate_types = target.rustc_crate_types();
let root = package.get_root();
let primary = cx.primary;
let rustcs = try!(prepare_rustc(package, target, crate_types, cx, req));
- let _ = cx.config.shell().verbose(|shell| {
- for &(ref rustc, _) in rustcs.iter() {
- try!(shell.status("Running", rustc.to_string()));
- }
- Ok(())
- });
-
Ok(rustcs.move_iter().map(|(rustc, kind)| {
let name = package.get_name().to_string();
+ let desc = rustc.to_string();
(proc() {
if primary {
}))
}
Ok(())
- }, kind)
+ }, kind, desc)
}).collect())
}
fn rustdoc(package: &Package, target: &Target,
- cx: &mut Context) -> CargoResult<Work> {
+ cx: &mut Context) -> CargoResult<(Work, String)> {
let kind = KindTarget;
let pkg_root = package.get_root();
let cx_root = cx.layout(kind).proxy().dest().join("doc");
log!(5, "commands={}", rustdoc);
- let _ = cx.config.shell().verbose(|shell| {
- shell.status("Running", rustdoc.to_string())
- });
-
let primary = cx.primary;
let name = package.get_name().to_string();
- Ok(proc() {
+ let desc = rustdoc.to_string();
+ Ok((proc() {
if primary {
try!(rustdoc.exec().chain_error(|| {
human(format!("Could not document `{}`.", name))
}))
}
Ok(())
- })
+ }, desc))
}
fn build_base_args(cx: &Context, mut cmd: ProcessBuilder,
assert_that(p.cargo_process("bench").arg("-v").arg("hello"),
execs().with_stdout(format!("\
-{running} `rustc src[..]foo.rs [..]`
{compiling} foo v0.5.0 ({url})
+{running} `rustc src[..]foo.rs [..]`
{running} `[..]target[..]release[..]foo-[..] hello --bench`
running 1 test
assert_that(p.cargo_process("bench").arg("-v"),
execs().with_status(0)
.with_stdout(format!("\
+{compiling} bar v0.0.1 ({dir})
{running} [..]
+{compiling} foo v0.0.1 ({dir})
{running} [..]
{running} [..]
{running} [..]
-{compiling} bar v0.0.1 ({dir})
-{compiling} foo v0.0.1 ({dir})
{running} [..]target[..]release[..]bench-[..]
running 1 test
assert_that(p.process(cargo_dir().join("cargo")).arg("bench").arg("-v"),
execs().with_status(0)
.with_stdout(format!("\
-{running} [..]
-{running} [..]
-{running} [..]
-{running} [..]
{fresh} bar v0.0.1 ({dir})
{fresh} foo v0.0.1 ({dir})
{running} [..]target[..]release[..]bench-[..]
.file("src/lib.rs", "");
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0).with_stdout(format!("\
+{compiling} test v0.0.0 ({url})
{running} `rustc {dir}{sep}src{sep}lib.rs --crate-name test --crate-type lib -g \
-C metadata=[..] \
-C extra-filename=-[..] \
--dep-info [..] \
-L {dir}{sep}target \
-L {dir}{sep}target{sep}deps`
-{compiling} test v0.0.0 ({url})\n",
+",
running = RUNNING, compiling = COMPILING, sep = path::SEP,
dir = p.root().display(),
url = p.url(),
.file("src/lib.rs", "");
assert_that(p.cargo_process("build").arg("-v").arg("--release"),
execs().with_status(0).with_stdout(format!("\
+{compiling} test v0.0.0 ({url})
{running} `rustc {dir}{sep}src{sep}lib.rs --crate-name test --crate-type lib \
--opt-level 3 \
--cfg ndebug \
--dep-info [..] \
-L {dir}{sep}target{sep}release \
-L {dir}{sep}target{sep}release{sep}deps`
-{compiling} test v0.0.0 ({url})\n",
+",
running = RUNNING, compiling = COMPILING, sep = path::SEP,
dir = p.root().display(),
url = p.url(),
.file("foo/src/lib.rs", "");
assert_that(p.cargo_process("build").arg("-v").arg("--release"),
execs().with_status(0).with_stdout(format!("\
+{compiling} foo v0.0.0 ({url})
{running} `rustc {dir}{sep}foo{sep}src{sep}lib.rs --crate-name foo \
--crate-type dylib --crate-type rlib \
--opt-level 3 \
--dep-info [..] \
-L {dir}{sep}target{sep}release{sep}deps \
-L {dir}{sep}target{sep}release{sep}deps`
+{compiling} test v0.0.0 ({url})
{running} `rustc {dir}{sep}src{sep}lib.rs --crate-name test --crate-type lib \
--opt-level 3 \
--cfg ndebug \
--extern foo={dir}{sep}target{sep}release{sep}deps/\
{prefix}foo-[..]{suffix} \
--extern foo={dir}{sep}target{sep}release{sep}deps/libfoo-[..].rlib`
-{compiling} foo v0.0.0 ({url})
-{compiling} test v0.0.0 ({url})\n",
+",
running = RUNNING,
compiling = COMPILING,
dir = p.root().display(),
.arg("-v"),
execs().with_status(101)
.with_stdout(format!("\
+{compiling} foo v0.5.0 ({url})
{running} `rustc src/foo.rs --crate-name foo --crate-type bin -g \
--out-dir {dir}{sep}target{sep}{target} \
--dep-info [..] \
-C ar=my-ar-tool -C linker=my-linker-tool \
-L {dir}{sep}target{sep}{target} \
-L {dir}{sep}target{sep}{target}{sep}deps`
-{compiling} foo v0.5.0 ({url})
",
running = RUNNING,
compiling = COMPILING,
.file("src/lib.rs", "");
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0).with_stdout(format!("\
+{compiling} test v0.0.0 ({url})
{running} `rustc {dir}{sep}src{sep}lib.rs --crate-name test --crate-type lib \
--opt-level 1 \
--cfg ndebug \
--dep-info [..] \
-L {dir}{sep}target \
-L {dir}{sep}target{sep}deps`
-{compiling} test v0.0.0 ({url})\n",
+",
running = RUNNING, compiling = COMPILING, sep = path::SEP,
dir = p.root().display(),
url = p.url(),
.file("foo/src/lib.rs", "");
assert_that(p.cargo_process("build").arg("-v").arg("--release"),
execs().with_status(0).with_stdout(format!("\
+{compiling} foo v0.0.0 ({url})
{running} `rustc {dir}{sep}foo{sep}src{sep}lib.rs --crate-name foo \
--crate-type dylib --crate-type rlib \
--opt-level 1 \
--dep-info [..] \
-L {dir}{sep}target{sep}release{sep}deps \
-L {dir}{sep}target{sep}release{sep}deps`
+{compiling} test v0.0.0 ({url})
{running} `rustc {dir}{sep}src{sep}lib.rs --crate-name test --crate-type lib \
--opt-level 1 \
-g \
--extern foo={dir}{sep}target{sep}release{sep}deps/\
{prefix}foo-[..]{suffix} \
--extern foo={dir}{sep}target{sep}release{sep}deps/libfoo-[..].rlib`
-{compiling} foo v0.0.0 ({url})
-{compiling} test v0.0.0 ({url})\n",
+",
running = RUNNING,
compiling = COMPILING,
dir = p.root().display(),
assert_that(p.cargo_process("test").arg("-v").arg("hello"),
execs().with_stdout(format!("\
-{running} `rustc src[..]foo.rs [..]`
{compiling} foo v0.5.0 ({url})
+{running} `rustc src[..]foo.rs [..]`
{running} `[..]target[..]foo-[..] hello`
running 1 test